home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / rayshade-4.0.6.3 / fixes / fix013 / text0000.txt < prev   
Encoding:
Text File  |  1994-08-09  |  3.5 KB  |  95 lines

  1. Forwarded message:
  2.  From halt@dsd.es.com Fri Jul  9 01:42:06 1993
  3. Errors-To: core-owner%itchy@dsd.es.com
  4. Errors-To: core-owner%itchy@dsd.es.com
  5. Date: Thu, 8 Jul 93 13:05:19 -0700
  6. Message-Id: <9307082005.AA14560@itchy>
  7. Errors-To: core-owner%itchy@dsd.es.com
  8. Reply-To: core@dsd.es.com (TraceCore Mailing List)
  9. From: Craig Kolb <cek@princeton.edu>
  10. Subject: Re:  hf's inside csg's problem
  11. List-Name: tracecore
  12. Precedence: Bulk
  13. Apparently-To: nfotis@theseas.ntua.gr
  14.  
  15. > I've been trying to figure out the problem that was brought up
  16. > about using heightfields in CSG objects.
  17. > [...]
  18. > What appears to be happening
  19. > is that mindist is being passed in as 2.09878, the call to OutOfBounds()
  20. > fails and hitpos is being set back equal to ray->pos resulting in hitpos.y
  21. > being negative [...]
  22.  
  23. This is a bug in 4.0.6 -- see the attached bugfix.  In short, the
  24. entire "else" clause in the HF bbox test is bogus.  Nuke it.
  25.  
  26. >A few questions --  What is the actual purpose of mindist?  I was
  27. >under the impression that it was a "fudge" factor to keep rays being fired
  28. >off an object from hitting that object again (due to round off errors).  With
  29. >CSG objects, is mindist supposed to help narrow the range being searched
  30. >(i.e. only look for the objects between mindist and maxdist rather than
  31. >from 0 (or EPSILON) to maxdist (since there is something closer at mindist??)).
  32.  
  33. Yup, exactly.  The intersection routines are supposed to return the
  34. closest intersection betwheen "mindist" and "maxdist" along the ray
  35.  
  36. Craig
  37.  
  38. ---
  39.  
  40. I've discovered a bug in rayshade's heightfield rendering code.
  41. This bug could cause rayshade to dump core, especially when
  42. rendering transparent height fields or heightfields that
  43. cast "long" shadows.
  44.  
  45. The fix will appear in the next release.  If you wish to fix
  46. the bug before then, edit libray/libobj/hf.c.  Lines 202-214 read:
  47.  
  48.         /*
  49.          * Find where we hit the hf cube.
  50.          */
  51.         VecAddScaled(ray->pos, mindist, ray->dir, &hitpos);
  52.         if (OutOfBounds(&hitpos, hf->boundbox)) {
  53.                 offset = *maxdist;
  54.                 if (!BoundsIntersect(ray, hf->boundbox, mindist, &offset))
  55.                         return FALSE;
  56.                 hitpos.x = ray->pos.x + ray->dir.x * offset;
  57.                 hitpos.y = ray->pos.y + ray->dir.y * offset;
  58.                 hitpos.z = ray->pos.z + ray->dir.z * offset;
  59.         } else
  60.                 hitpos = ray->pos;
  61.  
  62.  
  63. To fix the bug, remove the "else" case entirely, to make the
  64. block of code read:
  65.  
  66.  
  67.         /*
  68.          * Find where we hit the hf cube.
  69.          */
  70.         VecAddScaled(ray->pos, mindist, ray->dir, &hitpos);
  71.         if (OutOfBounds(&hitpos, hf->boundbox)) {
  72.                 offset = *maxdist;
  73.                 if (!BoundsIntersect(ray, hf->boundbox, mindist, &offset))
  74.                         return FALSE;
  75.                 hitpos.x = ray->pos.x + ray->dir.x * offset;
  76.                 hitpos.y = ray->pos.y + ray->dir.y * offset;
  77.                 hitpos.z = ray->pos.z + ray->dir.z * offset;
  78.         }
  79.  
  80.  
  81. Run "make", making sure that rayshade (and raypaint, if appropriate)
  82. are re-linked, and you should be all set.
  83.  
  84.  
  85. -- 
  86. Nick (Nikolaos) Fotis         National Technical Univ. of Athens, Greece
  87. HOME: 16 Esperidon St.,       InterNet : nfotis@theseas.ntua.gr
  88.       Halandri, GR - 152 32   UUCP:    mcsun!pythia!theseas!nfotis
  89.       Athens, GREECE          FAX: (+30 1) 77 84 578
  90.  
  91. USENET Editor of comp.graphics Resource Listing and soc.culture.greece FAQ
  92. NTUA/UA ACM Student Chapter Chair - we're organizing a small conference
  93.         in Comp. Graphics, call if you're interested to participate.
  94.  
  95.